export class Enum {
  constructor(defaultItems = [Object]) {
    this.items = defaultItems;
  }

  itemByValue(value) {
    if (value === null || value === undefined || value === '') {
      return '';
    }
    return this.items.find(item => {
      return item.value === value;
    });
  }

  itemByLabel(label) {
    if (label === null || label === undefined || label === '') {
      return '';
    }
    return this.items.find(item => {
      return item.label === label;
    });
  }

  getValues() {
    let values = [];
    this.items.forEach(item => {
      values.push(item.value);
    });
    return values;
  }

  getLabels() {
    let labels = [];
    this.items.forEach(item => {
      labels.push(item.label);
    });
    return labels;
  }

  /**
   * 根据枚举文本获取枚举值
   * @param label
   * @returns {null|String}
   */
  value(label) {
    if (label === null || label === undefined) {
      return null;
    }
    const enumMaps = this.items.find(item => {
      return item.label === label;
    });
    return enumMaps['value'];
  }

  color(value) {
    if (value === null || value === undefined) {
      return '';
    }
    const enumMaps = this.items.find(item => {
      return item.value === value;
    });
    return enumMaps['color'];
  }

  /**
   * 根据枚举值获取枚举文本
   * @param value
   * @returns {null|String}
   */
  label(value) {
    if (value === null || value === undefined) {
      return '';
    }
    const enumMaps = this.items.find(item => {
      return item.value === value;
    });
    return enumMaps['label'];
  }

  /**
   * 根据枚举值获取枚举文本
   * @param value
   * @returns {null|String}
   */
  icon(value) {
    if (value === null || value === undefined) {
      return '';
    }
    const enumMaps = this.items.find(item => {
      return item.value === value;
    });
    return enumMaps['icon'];
  }
}

/**
 * 默认是否项
 */
export const Bool = [
  {
    value: true,
    label: '是'
  },
  {
    value: false,
    label: '否'
  }
];

/**
 * AI分析状态
 */
export const AiScanStatus = [
  {
    value: 0,
    label: '等待分析',
    color: '#909399',
    icon: ''
  },
  {
    value: 1,
    label: '分析完成',
    color: '#67C23A',
    icon: ''
  },
  {
    value: 2,
    label: '分析异常',
    color: '#F56C6C',
    icon: ''
  }
];
/**
 * AI分析状态
 */
export const AiScanStatusExpend = [
  {
    value: 3,
    label: '等待分析',
    color: '#909399',
    icon: ''
  },
  {
    value: 4,
    label: '正在分析',
    color: '#909399',
    icon: ''
  }
];
/**
 * NLP分析状态
 */
export const nlpScanStatus = [
  {
    value: 0,
    label: '未分析',
    color: '#909399',
    icon: ''
  },
  {
    value: 1,
    label: '分析完成',
    color: '#67C23A',
    icon: ''
  },
  {
    value: 2,
    label: '分析异常',
    color: '#F56C6C',
    icon: ''
  }
];
// 评定状态枚举值
export const isEvaluateList = [
  {
    value: 0,
    label: '未评价'
  },
  {
    value: 1,
    label: '已评价'
  }
];

export const roleType = [
  {
    value: 1,
    label: '运营管理员'
  },
  {
    value: 647,
    label: '扫描员'
  },
  {
    value: 665,
    label: '诊断医生'
  },
  {
    value: 681,
    label: '调度员'
  }
];

// 可疑状态
export const suspiciousStatus = [
  {
    value: 1,
    label: '高风险',
    color: 'red'
  },
  {
    value: 2,
    label: '低风险',
    color: 'green'
  },
  {
    value: 3,
    label: '未分析',
    color: 'grey'
  }
];
